﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjetoWebsite
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["usuario"] == null)
            {
                lblUser.Text = "";
                btnDadosCdstr.Visible = false;
                btnLogout.Visible = false;
                btnPedidos.Visible = false;
                btnCarrinho.Visible = false;
            }
            else
            {
                lblUser.Text = "Bem vindo(a), " + Session["usuario"];
                btnCadastro.Visible = false;
                btnLogin.Visible = false;
            }
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (Session["usuario"] == null)
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void btnCadastro_Click(object sender, EventArgs e)
        {
            if (Session["usuario"] == null)
            {
                Response.Redirect("Cadastro.aspx");
            }
        }

        protected void btnPedidos_Click(object sender, EventArgs e)
        {
            if (Session["usuario"] != null)
            {
                Response.Redirect("VisualizarPedidos.aspx");
            }
        }

        protected void btnDadosCdstr_Click(object sender, EventArgs e)
        {
            if (Session["usuario"] != null)
            {
                Response.Redirect("VisualizarDadosCadastrais.aspx");
            }
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            if (Session["usuario"] != null)
            {
                Session["usuario"] = null;
                Session["email"] = null;
                Session["senha"] = null;

                Response.Redirect("Default.aspx");
            }
        }

        protected void imgLogo_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
        }

        protected void btnCarrinho_Click(object sender, EventArgs e)
        {
            Response.Redirect("VisualizarCarrinho.aspx");
        }
    }
}